<!DOCTYPE html>
<script src="resources/shadow-dom.js"></script>
<div>PASS unless crash.</div>
<div id="sandbox"></div>
<script>
if (window.testRunner)
    testRunner.dumpAsText();

sandbox.appendChild(
    createDOM('div', {'id': 'shadow-host'},
              createShadowRoot(
                  createDOM('div', {'id': 'shadow-root-child'},
                            document.createTextNode('foo')))));

sandbox.offsetLeft;

function gestureTap(elementId)
{
    var element = getNodeInComposedTree(elementId);
    if (window.eventSender) {
        eventSender.gestureTap(element.offsetLeft + element.offsetWidth / 2, element.offsetTop + element.offsetHeight / 2);
        eventSender.leapForward(10);
        eventSender.keyDown(' ');
    }
}

var shadowRootChild = getNodeInComposedTree('shadow-host/shadow-root-child');
shadowRootChild.addEventListener('mousedown', function() {
    shadowRootChild.remove();
});

gestureTap('shadow-host/shadow-root-child');
</script>
